using System.ComponentModel;
using System.Text.Json.Serialization;
using Bread.Utility;

namespace Bread.Mvc;

public abstract class Model : INotifyPropertyChanged
{
    [JsonIgnore]
    public bool IsDataChanged { get; set; } = false;

    [JsonIgnore]
    public bool IsSuspened { get; set; } = false;

    public event PropertyChangedEventHandler? PropertyChanged;


    protected virtual void OnPropertyChanged(string name)
    {
        if (IsSuspened) return;
        IsDataChanged = true;
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }


    public virtual void LoadFrom(INIConfig config) { }

    public virtual void SaveTo(INIConfig config) { }

    public virtual void Clear() { }
}
